package me.itsoo.artemis.framework.core.converter;

import me.itsoo.artemis.framework.core.collect.ImmutableMap;

import java.util.Map;

/**
 * TypeConvertor
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/5/18
 */
public interface TypeConvertor {

    /**
     * 基本类型转换器
     */
    Map<Class<?>, TypeConvertor> TYPE_CONVERTORS = ImmutableMap.<Class<?>, TypeConvertor>builder()
            .put(Boolean.class, new BooleanTypeConvertor())
            .put(boolean.class, new BooleanTypeConvertor())
            .put(String.class, new StringTypeConvertor())
            .put(Character.class, new CharacterTypeConvertor())
            .put(char.class, new CharacterTypeConvertor())
            .build();

    /**
     * 类型转换
     *
     * @param value Object
     * @return Object
     */
    Object convertIfNecessary(Object value);

}
